﻿ CREATE proc danhmucphongBan_sua        
@MaPB varchar(25),        
@TenPB nvarchar(200),    
@MaPBMoi varchar(25)        
as        
declare @dem as int            
select @dem=COUNT(*) from  DanhMuc_PhongBan where MaPB=@MaPBMoi and  MaPB <> @MaPB         
if(@dem>0)            
begin            
select ErrCode=0            
          
end            
else            
begin            
            
update  DanhMuc_PhongBan set MaPB=@MaPBMoi,TenPB=@TenPB  where  MaPB=@MaPB          
select ErrCode=1            
end                        